package com.start.security;

import com.alibaba.fastjson2.JSONObject;
import com.start.common.details.BaseUserDetails;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;

@Data
 @Schema(name="StartUserContext", description = "用户上下文信息")
public class StartUserContext {
     @Schema(name="当前用户")
    private String userId;
     @Schema(name="用户类型")
    private String startUserType;
     @Schema(name="用户扩展属性")
    private JSONObject prop;

    public static StartUserContext create(BaseUserDetails user) {
        return create(user, null);
    }

    public static StartUserContext create(BaseUserDetails user, JSONObject prop) {
        StartUserContext serverContext = new StartUserContext();
        serverContext.setUserId(user.getUserId());
        serverContext.setStartUserType(user.getStartUserType());
        if (prop != null) {
            serverContext.setProp(prop);
        }
        return serverContext;
    }


}
